import "package:flutter/material.dart";
import "MovieButtonMenu.dart";
import "MovieCardList.dart";

/// 影视排行榜
class MovieRank extends StatefulWidget {
  final List<MovieCard> cardList;
  const MovieRank({super.key, required this.cardList});
  @override
  State<MovieRank> createState() => _MovieRankState();
}

class _MovieRankState extends State<MovieRank> {
  String activeValue = "0"; //初始化选中值
  List<ButtonMenuItem> items = [
    ButtonMenuItem(label: "免费榜", value: "0"),
    ButtonMenuItem(label: "新片榜", value: "1"),
    ButtonMenuItem(label: "纪录片榜", value: "2"),
    ButtonMenuItem(label: "电视剧榜", value: "3"),
    ButtonMenuItem(label: "综艺榜", value: "4"),
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        children: [
          Padding(
            padding: const EdgeInsets.only(bottom: 10),
            child: MovieButtonMenu(
              items: items,
              activeValue: activeValue,
              onTap: (value) {
                setState(() {
                  activeValue = value;
                });
              },
            ),
          ),
          MovieCardList(
            cardList: widget.cardList,
            size: CardSize.small,
          ),
        ],
      ),
    );
  }
}
